import allure
import requests


def post(url,json_data=None,data=None,params=None,headers=None):

    request = requests.post(url=url, json=json_data,data=data,params=params,headers=headers)
    allure.attach('POST', "请求的方式")
    allure.attach(request.url, "请求的url")
    allure.attach(str(json_data), "请求的体", allure.attachment_type.TEXT)
    # 状态码
    status_code = str(request.status_code)
    allure.attach(status_code, "状态码")
    # allure.attach(str(request.json()), "请求结果", allure.attachment_type.TEXT)
    return request


def get(url,params=None,json_data=None,headers=None):
    request = requests.get(url=url,params=params,headers=headers)
    allure.attach('GET', "请求的方式")
    allure.attach(request.url, "请求的url")
    allure.attach(str(json_data), "请求的体", allure.attachment_type.TEXT)
    # 状态码
    status_code = str(request.status_code)
    allure.attach(status_code, "状态码")
    # allure.attach(str(request.json()), "请求结果", allure.attachment_type.TEXT)
    return request

